<template>
  <div class="gl_px_15">
    <el-tabs v-model="teamActive" @tab-click="handleClick">
      <el-tab-pane label="总排名" name="total">
        <total v-if="isFirst" ref="total" :point-type="pointType" />
      </el-tab-pane>
      <el-tab-pane label="竞技排名" name="sports">
        <sports v-if="isSecond" ref="sports" :point-type="pointType" />
      </el-tab-pane>
      <el-tab-pane label="品势排名" name="poomsae">
        <poomsae v-if="isThird" ref="poomsae" :point-type="pointType" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import total from './team/teamTotal';
import sports from './team/teamSports';
import poomsae from './team/teamPoomsae';

export default {
  name: 'TeamRank',
  components: {
    total,
    sports,
    poomsae
  },
  props: {
    pointTypeCode: {
      required: true,
      type: String,
      default: ''
    },
    refresh: {
      required: true,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      teamActive: 'total',
      pointType: '',
      isFirst: true,
      isSecond: false,
      isThird: false
    };
  },
  watch: {
    pointTypeCode: {
      handler (newVal, oldVal) {
        if (newVal && newVal !== oldVal) {
          this.pointType = newVal;
        }
      }
    },
    refresh: {
      handler (newVal) {
        if (newVal === 'teamRank') {
          this.$refs[this.teamActive].findTabelDataList();
        }
      }
    }
  },
  created() {
    this.pointType = this.pointTypeCode;
  },
  methods: {
    handleClick(tab) {
      if (tab.name === 'total') {
        this.isFirst = true;
        this.isSecond = false;
        this.isThird = false;
      } else if (tab.name === 'sports') {
        this.isFirst = false;
        this.isSecond = true;
        this.isThird = false;
      } else if (tab.name === 'poomsae') {
        this.isFirst = false;
        this.isSecond = false;
        this.isThird = true;
      }
    }
  }
};
</script>
<style scoped>

</style>
